<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exslt="http://exslt.org/common"
  xmlns:func="http://exslt.org/functions"
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:a="&a;"
  xmlns:o="&a;VersaQueryService#view"
  xmlns:e="&a;editor-common#"
  xmlns:vrx="http://www.w3.org/2005/versa-results#"
  xmlns:w="http://xmlns.heustics.org/xslt/ext/wiki/0.1/"
  extension-element-prefixes="func w"
  exclude-result-prefixes="xsl exslt func o e a l vrx"
> 
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;VersaQueryService#view')"/>
  <xsl:variable name="o:results-l10n" select="$o:l10n/*[@name='versa-results']/*"/>
  <xsl:variable name="o:params-l10n" select="$o:l10n/*[@name='params']/*"/>
  <xsl:variable name="o:hints-l10n" select="$o:l10n/*[@name='hints']/*"/> 
  <xsl:variable name="o:boolean-l10n" select="$o:l10n/*[@name='boolean-values']/*"/>
  <xsl:variable name="o:data-types-l10n" select="$o:l10n/*[@name='data-types']/*"/>
  
    
  <!-- xsl:template match="a:search-params" mode="a:search-url-str">
    <xsl:value-of select="a:format-repeat-request()"/>
    <xsl:apply-templates mode="a:search-url-param-str"/>
    <xsl:choose>
      <xsl:when test="$o:layout = 'col' or $o:layout = 'row'">
        <xsl:value-of select="concat('&amp;versa-layout=',$o:layout)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>col</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template -->
  
  <xsl:template match="a:query" mode="a:input-show">
    <xsl:call-template name="a:query-input-show">
      <xsl:with-param name="help-markup" select="$o:l10n/*[@name='query-help-markup']"/>
    </xsl:call-template>
  </xsl:template>
      
  <xsl:template match="a:search-results" mode="a:input-show">
    <xsl:param name="url"/>
    <div class="versa-results">
      <h3>
        <xsl:value-of select="$o:results-l10n[@key='title']"/>
      </h3>
      <div class="versa-results-body">
        <ul>
          <li>
            <xsl:apply-templates mode="vrx:versa-results">
              <xsl:with-param name="vars" select="vrx:head/vrx:variable"/>
              <xsl:with-param name="url" select="$url"/>
            </xsl:apply-templates>
          </li>
        </ul>
        <div class="spacer versa-results-body-spacer"/>
      </div>
      <div class="spacer versa-results-spacer"/>
    </div>
  </xsl:template>
  
  <xsl:template match="Boolean" mode="vrx:versa-results">
    <xsl:variable name="type" select="local-name()"/>
    <xsl:variable name="value" select="string(.)"/>
    <div class="versa-result versa-result-{$type}">
      <div class="versa-key versa-key-{$type}">
        <span><xsl:value-of select="$o:data-types-l10n[@key=$type]"/></span>
        <div class="spacer versa-spacer-key versa-spacer-{$type}"/>
      </div>
      <div class="versa-value versa-value-leaf versa-value-{$type}">
        <span>
          <xsl:value-of select="$o:boolean-l10n[@key=$value]"/>
        </span>
        <div class="spacer versa-spacer-value versa-spacer-{$type}"/>
      </div>
    </div>
  </xsl:template>
  
  <xsl:template match="String|Number" mode="vrx:versa-results">
    <xsl:variable name="type" select="local-name()"/>
    <div class="versa-result versa-result-{$type}">
      <div class="versa-key versa-key-{$type}">
        <span><xsl:value-of select="$o:data-types-l10n[@key=$type]"/></span>
        <div class="spacer versa-spacer-key versa-spacer-{$type}"/>
      </div>
      <div class="versa-value versa-value-leaf versa-value-{$type}">
        <span>
          <xsl:value-of select="."/>
        </span>
        <div class="spacer versa-spacer-spacer versa-spacer-{$type}"/>
      </div>
    </div>
  </xsl:template>
  
  <xsl:template match="Resource" mode="vrx:versa-results">
    <xsl:variable name="type" select="local-name()"/>
    <div class="versa-result versa-result-{$type}">
      <div class="versa-key versa-key-{$type}">
        <span><xsl:value-of select="$o:data-types-l10n[@key=$type]"/></span>
        <div class="spacer versa-spacer-key versa-spacer-{$type}"/>
      </div>
      <div class="versa-value versa-value-leaf versa-value-{$type}">
        <a href="{.}">
          <xsl:value-of select="."/>
        </a>
        <div class="spacer versa-spacer-spacer versa-spacer-{$type}"/>
      </div>
    </div>
  </xsl:template>
  
  <xsl:template match="List|Set" mode="vrx:versa-results">
    <xsl:variable name="type" select="local-name()"/>
    <div class="versa-result versa-result-container versa-result-{$type}">
      <div class="versa-key versa-result-container-key versa-result-{$type}">
        <span><xsl:value-of select="$o:data-types-l10n[@key=$type]"/></span>
        <div class="spacer versa-key-spacer"/>
      </div>
      <div>
        <xsl:choose>
          <xsl:when test="*">
            <xsl:attribute name="class">versa-value versa-value-container versa-value-<xsl:value-of select="$type"/></xsl:attribute>
            <ul>
              <xsl:for-each select="*">
                <li>
                  <xsl:apply-templates select="." mode="vrx:versa-results"/>
                  <div class="spacer versa-spacer-container versa-spacer-{$type}"/>
                </li>
              </xsl:for-each>
            </ul>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="class">versa-value versa-value-container versa-value-<xsl:value-of select="$type"/> versa-container-empty</xsl:attribute>
            <span>
              <xsl:value-of select="$o:results-l10n[@key='no-results']"/>
            </span>
          </xsl:otherwise>
        </xsl:choose>
        <div class="spacer versa-spacer-value versa-spacer-container versa-spacer-{$type}"/>
      </div>
    </div>
  </xsl:template>
    
</xsl:stylesheet>

